<?php
if (!empty($r)) {
	$hidden = false;//loading from merchant account
	$anonymous_lbl = BUtils::T('anonymous_lbl');
?>
<table class="table table-striped table-customer">
	<tbody>
<?php
	$visit_time = Yii::app()->locale->dateFormatter->formatDateTime($r['ts_last_time'], null, 'short');
	if (empty($r['id_user'])) {
		$cust_name = $anonymous_lbl;
		$cust_url = Yii::app()->baseUrl . '/img/user-128.png';
		$cust_contact = '';
	} else {
		//set user name
		if (!empty($r['name'])) $cust_name = substr($r['name'], 0, strpos($r['name'], ' '));
		else $cust_name = $anonymous_lbl;
		
		//set active phone number/email
		$cust_contact = '<ul class="icons-ul">';
		if (!empty($r['mobile'])) {
			$cust_contact .= '<li><i class="icon-li icon-phone"></i> ' . CustomerHelper::getMobile($r['mobile'], $hidden) . '</li>';
		}
		if(!empty($r['email'])) {
			$cust_contact .= '<li><i class="icon-li icon-envelope-alt"></i> ' . CustomerHelper::getEmail($r['email'], $hidden) . '</li>';
		}
		$cust_contact .= '</ul>';
		
		//set user picture
		if (empty($r['picture'])) $cust_url = Yii::app()->baseUrl . '/img/user-128.png';
		else $cust_url = $r['picture'];
	}
?>
<tr>
	<td class="user user-bigger">
		<img src="<?php echo $cust_url; ?>" alt="" onerror="this.onerror=null;this.src='<?php echo Yii::app()->baseUrl; ?>/img/user-128.png';" />
	</td>
	<td class="uinfo">
		<div class="cust-name">
			<span class="blue"><?php echo $cust_name; ?></span>
		</div>
		<div class="cust-contact"><?php echo $cust_contact; ?></div>
		<div class="visit-time"><?php echo $visit_time; ?></div>
	</td>
	<td class="umessage">
		<h4 class="green">
			<strong><i class="icon-ok"></i></strong>
			<?php echo BUtils::T('points_to_customer_done_eg', array('{number}'=>"<strong>{$assigned_points}</strong>")); ?>
		</h4>
	</td>
</tr>
	</tbody>
</table>
<?php
} else {
?>
<div class="well well-large gray">
	<h3 class=""><?php echo BUtils::T('customers_no_title_lbl'); ?></h3>
	<p><?php echo BUtils::T('customers_not_found_eg'); ?></p>
</div>
<?php
}